package com.ufo.store.management.database;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;

import com.ufo.store.management.entity.Isszmbalv3BranchInfo;
import com.ufo.store.management.entity.Isszmbalv3Member;
import com.ufo.store.management.entity.Isszmbalv3MemberPointInfo;
import com.ufo.store.management.entity.Isszmbalv3PayFlow;
import com.ufo.store.management.entity.Isszmbalv3SaleDetailInfo;
import com.ufo.store.management.entity.Isszmbalv3StockInfo;
import com.ufo.store.management.entity.Member;
import com.ufo.store.management.entity.MemberPointInfo;
import com.ufo.store.management.entity.PayMaster;
import com.ufo.store.management.entity.SaleDetailInfo;
import com.ufo.store.management.entity.StockInfo;
import com.ufo.store.management.entity.Isszmbalv3SupcustInfo;
import com.ufo.store.management.utils.Utils;


import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 * Created by Administrator on 2015/9/23 0023.
 */
public class DatabaseManager {
    public static final String STOCK_TABLE_NAME = "stock";
    public static final String STOCK_STOCKID = "stockid";
    public static final String STOCK_STOCKNAME = "stockname";
    public static final String STOCK_GROUPID = "groupid";
    public static final String STOCK_UNIT = "unit";
    public static final String STOCK_TYPEID = "typeid";
    public static final String STOCK_COST = "cost";
    public static final String STOCK_RETAIL_PRICE = "retail_price";
    public static final String STOCK_MEMBER_PRICE = "member_price";
    public static final String STOCK_WHOLE_PRICE = "whole_price";
    public static final String STOCK_CAN_DISCOUNT = "can_discount";
    public static final String STOCK_FRONTEDN = "frontend";
    public static final String STOCK_PAUSE = "paused";
    public static final String STOCK_CLOSEOFF = "closeoff";
    public static final String STOCK_STORABLE = "storable";
    public static final String STOCK_STOCKTYPE = "stocktype";
    public static final String STOCK_BARCODE = "barcode";
    public static final String STOCK_STOCKPOS = "stockpos";
    public static final String STOCK_SPELL = "spell";
    public static final String STOCK_SUIT_FLAGE = "suit_flag";

    public static final String STOCK_TYPE_TABLE_NAME = "stock_type";
    public static final String STOCK_TYPE_TYPEID = "typeid";
    public static final String STOCK_TYPE_TYPENAME = "typename";
    public static final String STOCK_TYPE_FRONTEND = "frontend";
    public static final String STOCK_TYPE_DISCOUNT = "discount";

    public static final String MEMBER_TABLE_NAME = "member";
    public static final String MEMBER_MEMBERID = "memberid";
    public static final String MEMBER_NAME = "name";
    public static final String MEMBER_SEX = "sex";
    public static final String MEMBER_TELEPHONE = "telephone";
    public static final String MEMBER_MOBILE = "mobile";
    public static final String MEMBER_POST = "post";
    public static final String MEMBER_ADDR = "addr";
    public static final String MEMBER_EMAIL = "email";
    public static final String MEMBER_MEMO = "memo";
    public static final String MEMBER_BIRTHDAY = "birthday";
    public static final String MEMBER_CREATE_DATE = "create_date";
    public static final String MEMBER_CREATE_OPERID = "create_operid";
    public static final String MEMBER_STATE = "state";
    public static final String MEMBER_AMOUNT = "amount";
    public static final String MEMBER_OVERDRAFT = "overdraft";
    public static final String MEMBER_PASSWORD = "password";
    public static final String MEMBER_DISCOUNTE = "discount";
    public static final String MEMBER_POINT = "point";
    public static final String MEMBER_POINT_FLAG = "point_flag";
    public static final String MEMBER_PRICE_KIND = "price_kind";
    public static final String MEMBER_MEMBERTYPE = "membertype";
    public static final String MEMBER_CARDID = "cardid";
    public static final String MEMBER_CARD_MEDIUM = "card_medium";
    public static final String MEMBER_MODIFY_SN = "modify_sn";
    public static final String MEMBER_CARD_RECHARGE = "card_recharge";
    public static final String MEMBER_CARD_PRESENT = "card_present";
    public static final String MEMBER_CARD_CONSUME = "card_consume";
    public static final String MEMBER_TOTAL_CONSUME = "total_consume";
    public static final String MEMBER_CREATE_SHOPID = "create_shopid";
    public static final String MEMBER_EXPIRE_DATE = "expire_date";

    public static final String MEMBER_POINT_TABLE_NAME = "member_point";
    public static final String MEMBER_POINT_BILLNO = "billno";
    public static final String MEMBER_POINT_MEMBERID = "memberid";
    public static final String MEMBER_POINT_OPERDATE = "operdate";
    public static final String MEMBER_POINT_DIGEST = "digest";
    public static final String MEMBER_POINT_POINT = "point";
    public static final String MEMBER_POINT_ORIG_POINT = "orig_point";

    public static final String SALE_DETAIL_TABLE_NAME = "sale_detail";
    public static final String SALE_DETAIL_BILLNO = "billno";
    public static final String SALE_DETAIL_STOCKID = "stockid";
    public static final String SALE_DETAIL_QUANTITY = "quantity";
    public static final String SALE_DETAIL_OPERATEDATE = "operdate";
    public static final String SALE_DETAIL_PRICE = "price";
    public static final String SALE_DETAIL_COST = "cost";
    public static final String SALE_DETAIL_PRICE_ORIG = "price_orig";

    public static final String PAY_MASTER_TABLE_NAME = "pay_master";
    public static final String PAY_MASTER_BILLNO = "billno";
    public static final String PAY_MASTER_OPERDATE = "operdate";
    public static final String PAY_MASTER_BLOTOUT = "blotout";
    public static final String PAY_MASTER_TOTAL = "total";
    public static final String PAY_MASTER_RECEIVABLE = "receivable";

    //本地会员拼音检索
    public static final String MEMBER_NAME_SPELL = "name_spell";

    //本地存取数据库，用于保存fastfood商品
    public static final String LOCAL_STOCK_STOCKID_PRIMARY = "stockidprimary";

    //本地存取数据库，用于保存fastfood会员
    public static final String LOCAL_MEMBER_MEMBERID_PRIMARY = "memberidprimary";

    //本地存取数据库，用于保存fastfood销售额表主键
    public static final String LOCAL_PAY_MASTER_PRIMARY = "paymasterprimary";

    //本地存取数据库，用于保存fastfood销售详情主键
    public static final String LOCAL_SALE_DETAIL_PRIMARY = "saledetailprimary";

    //本地存取数据库，用于保存fastfood商品类目主键
    public static final String LOCAL_STOCK_TYPE_TABLE_NAME_PRIMARY = "stocktypeprimary";


    //Isszmbalv3数据库商品目录表(79项)
    public static final String ISSZMBALV3_t_bd_item_info_TABLE_NAME = "t_bd_item_info";
    public static final String ISSZMBALV3_t_bd_item_info_item_no = "item_no";
    public static final String ISSZMBALV3_t_bd_item_info_item_subno = "item_subno";
    public static final String ISSZMBALV3_t_bd_item_info_item_name = "item_name";
    public static final String ISSZMBALV3_t_bd_item_info_item_subname = "item_subname";
    public static final String ISSZMBALV3_t_bd_item_info_item_clsno = "item_clsno";
    public static final String ISSZMBALV3_t_bd_item_info_item_brand = "item_brand";
    public static final String ISSZMBALV3_t_bd_item_info_item_brandname = "item_brandname";
    public static final String ISSZMBALV3_t_bd_item_info_unit_no = "unit_no";
    public static final String ISSZMBALV3_t_bd_item_info_item_size = "item_size";
    public static final String ISSZMBALV3_t_bd_item_price = "price";
    public static final String ISSZMBALV3_t_bd_item_base_price = "base_price";
    public static final String ISSZMBALV3_t_bd_item_sale_price = "sale_price";
    public static final String ISSZMBALV3_t_bd_item_combine_sta = "combine_sta";
    public static final String ISSZMBALV3_t_bd_item_status = "status";
    public static final String ISSZMBALV3_t_bd_item_display_flag = "display_flag";
    public static final String ISSZMBALV3_t_bd_item_po_cycle = "po_cycle";
    public static final String ISSZMBALV3_t_bd_item_so_cycle = "so_cycle";
    public static final String ISSZMBALV3_t_bd_item_automin_flag = "automin_flag";
    public static final String ISSZMBALV3_t_bd_item_en_dis = "en_dis";
    public static final String ISSZMBALV3_t_bd_item_change_price = "change_price";
    public static final String ISSZMBALV3_t_bd_item_purchase_tax = "purchase_tax";
    public static final String ISSZMBALV3_t_bd_item_sale_tax = "sale_tax";
    public static final String ISSZMBALV3_t_bd_item_purchase_spec = "purchase_spec";
    public static final String ISSZMBALV3_t_bd_item_shipment_spec = "shipment_spec";
    public static final String ISSZMBALV3_t_bd_item_item_supcust = "item_supcust";
    public static final String ISSZMBALV3_t_bd_item_main_supcust = "main_supcust";
    public static final String ISSZMBALV3_t_bd_item_item_stock = "item_stock";
    public static final String ISSZMBALV3_t_bd_item_build_date = "build_date";
    public static final String ISSZMBALV3_t_bd_item_modify_date = "modify_date";
    public static final String ISSZMBALV3_t_bd_item_stop_date = "stop_date";
    public static final String ISSZMBALV3_t_bd_item_abc = "abc";
    public static final String ISSZMBALV3_t_bd_item_branch_price = "branch_price";
    public static final String ISSZMBALV3_t_bd_item_item_rem = "item_rem";
    public static final String ISSZMBALV3_t_bd_item_vip_price = "vip_price";
    public static final String ISSZMBALV3_t_bd_item_sale_min_price = "sale_min_price";
    public static final String ISSZMBALV3_t_bd_item_com_flag = "com_flag";
    public static final String ISSZMBALV3_t_bd_item_vip_acc_flag = "vip_acc_flag";
    public static final String ISSZMBALV3_t_bd_item_vip_acc_num = "vip_acc_num";
    public static final String ISSZMBALV3_t_bd_item_dpfm_type = "dpfm_type";
    public static final String ISSZMBALV3_t_bd_item_return_rate = "return_rate";
    public static final String ISSZMBALV3_t_bd_item_update_date = "update_date";
    public static final String ISSZMBALV3_t_bd_item_pro_code1 = "pro_code1";
    public static final String ISSZMBALV3_t_bd_item_pro_code2 = "pro_code2";
    public static final String ISSZMBALV3_t_bd_item_pro_code3 = "pro_code3";
    public static final String ISSZMBALV3_t_bd_item_pro_code4 = "pro_code4";
    public static final String ISSZMBALV3_t_bd_item_pro_code5 = "pro_code5";
    public static final String ISSZMBALV3_t_bd_item_pro_code6 = "pro_code6";
    public static final String ISSZMBALV3_t_bd_item_item_picture = "item_picture";
    public static final String ISSZMBALV3_t_bd_item_sale_flag = "sale_flag";
    public static final String ISSZMBALV3_t_bd_item_scheme_price = "scheme_price";
    public static final String ISSZMBALV3_t_bd_item_vip_price2 = "vip_price2";
    public static final String ISSZMBALV3_t_bd_item_vip_price3 = "vip_price3";
    public static final String ISSZMBALV3_t_bd_item_vip_price4 = "vip_price4";
    public static final String ISSZMBALV3_t_bd_item_vip_price5 = "vip_price5";
    public static final String ISSZMBALV3_t_bd_item_valid_days = "valid_days";
    public static final String ISSZMBALV3_t_bd_item_memo = "memo";
    public static final String ISSZMBALV3_t_bd_item_item_com = "item_com";
    public static final String ISSZMBALV3_t_bd_item_product_area = "product_area";
    public static final String ISSZMBALV3_t_bd_item_measure_flag = "measure_flag";
    public static final String ISSZMBALV3_t_bd_item_item_sup_flag = "item_sup_flag";
    public static final String ISSZMBALV3_t_bd_item_sup_rate = "sup_rate";
    public static final String ISSZMBALV3_t_bd_item_picture_type = "picture_type";
    public static final String ISSZMBALV3_t_bd_item_base_price1 = "base_price1";
    public static final String ISSZMBALV3_t_bd_item_base_price2 = "base_price2";
    public static final String ISSZMBALV3_t_bd_item_base_price3 = "base_price3";
    public static final String ISSZMBALV3_t_bd_item_base_price4 = "base_price4";
    public static final String ISSZMBALV3_t_bd_item_base_price5 = "base_price5";
    public static final String ISSZMBALV3_t_bd_item_base_price6 = "base_price6";
    public static final String ISSZMBALV3_t_bd_item_base_price7 = "base_price7";
    public static final String ISSZMBALV3_t_bd_item_base_price8 = "base_price8";
    public static final String ISSZMBALV3_t_bd_item_new_oper_id = "new_oper_id";
    public static final String ISSZMBALV3_t_bd_item_modify_oper_id = "modify_oper_id";
    public static final String ISSZMBALV3_t_bd_item_en_gift = "en_gift";
    public static final String ISSZMBALV3_t_bd_item_promote_flag = "promote_flag";
    public static final String ISSZMBALV3_t_bd_item_allow_flag = "allow_flag";
    public static final String ISSZMBALV3_t_bd_item_hand_flag = "hand_flag";
    public static final String ISSZMBALV3_t_bd_item_alert_day1 = "alert_day1";
    public static final String ISSZMBALV3_t_bd_item_alert_day2 = "alert_day2";
    public static final String ISSZMBALV3_t_bd_item_fresh_sque = "fresh_sque";
    public static final String ISSZMBALV3_t_bd_item_quickclearing = "quickclearing";   //如下为思讯8新增字段
    public static final String ISSZMBALV3_t_bd_item_is_fast = "is_fast";
    public static final String ISSZMBALV3_t_bd_item_multiunit_flag = "multiunit_flag";

    //Isszmbalv3数据库会员目录表(83项)
    public static final String ISSZMBALV3_t_rm_vip_info_TABLE_NAME = "t_rm_vip_info";
    public static final String ISSZMBALV3_t_rm_vip_card_id = "card_id";
    public static final String ISSZMBALV3_t_rm_vip_card_no = "card_no";
    public static final String ISSZMBALV3_t_rm_vip_card_type = "card_type";
    public static final String ISSZMBALV3_t_rm_vip_vip_name = "vip_name";
    public static final String ISSZMBALV3_t_rm_vip_vip_sex = "vip_sex";
    public static final String ISSZMBALV3_t_rm_vip_vip_add = "vip_add";
    public static final String ISSZMBALV3_t_rm_vip_vip_zip = "vip_zip";
    public static final String ISSZMBALV3_t_rm_vip_vip_tel = "vip_tel";
    public static final String ISSZMBALV3_t_rm_vip_vip_email = "vip_email";
    public static final String ISSZMBALV3_t_rm_vip_vip_tax = "vip_tax";
    public static final String ISSZMBALV3_t_rm_vip_card_status = "card_status";
    public static final String ISSZMBALV3_t_rm_vip_oper_id = "oper_id";
    public static final String ISSZMBALV3_t_rm_vip_oper_date = "oper_date";
    public static final String ISSZMBALV3_t_rm_vip_vip_start_date = "vip_start_date";
    public static final String ISSZMBALV3_t_rm_vip_vip_end_date = "vip_end_date";
    public static final String ISSZMBALV3_t_rm_vip_use_num = "use_num";
    public static final String ISSZMBALV3_t_rm_vip_birthday = "birthday";
    public static final String ISSZMBALV3_t_rm_vip_social_id = "social_id";
    public static final String ISSZMBALV3_t_rm_vip_save_amt = "save_amt";
    public static final String ISSZMBALV3_t_rm_vip_residual_amt = "residual_amt";
    public static final String ISSZMBALV3_t_rm_vip_consum_amt = "consum_amt";
    public static final String ISSZMBALV3_t_rm_vip_consum_count = "consum_count";
    public static final String ISSZMBALV3_t_rm_vip_company = "company";
    public static final String ISSZMBALV3_t_rm_vip_duty = "duty";
    public static final String ISSZMBALV3_t_rm_vip_degree = "degree";
    public static final String ISSZMBALV3_t_rm_vip_mobile = "mobile";
    public static final String ISSZMBALV3_t_rm_vip_homeplace = "homeplace";
    public static final String ISSZMBALV3_t_rm_vip_reg_place = "reg_place";
    public static final String ISSZMBALV3_t_rm_vip_live_place = "live_place";
    public static final String ISSZMBALV3_t_rm_vip_marriage = "marriage";
    public static final String ISSZMBALV3_t_rm_vip_salary_level = "salary_level";
    public static final String ISSZMBALV3_t_rm_vip_nation = "nation";
    public static final String ISSZMBALV3_t_rm_vip_height = "height";
    public static final String ISSZMBALV3_t_rm_vip_weight = "weight";
    public static final String ISSZMBALV3_t_rm_vip_blood_type = "blood_type";
    public static final String ISSZMBALV3_t_rm_vip_favor = "favor";
    public static final String ISSZMBALV3_t_rm_vip_now_acc_num = "now_acc_num";
    public static final String ISSZMBALV3_t_rm_vip_acc_num = "acc_num";
    public static final String ISSZMBALV3_t_rm_vip_dec_num = "dec_num";
    public static final String ISSZMBALV3_t_rm_vip_pass = "pass";
    public static final String ISSZMBALV3_t_rm_vip_modify_date = "modify_date";
    public static final String ISSZMBALV3_t_rm_vip_com_flag = "com_flag";
    public static final String ISSZMBALV3_t_rm_vip_photo = "photo";
    public static final String ISSZMBALV3_t_rm_vip_memo = "memo";
    public static final String ISSZMBALV3_t_rm_vip_father_card = "father_card";
    public static final String ISSZMBALV3_t_rm_vip_item_amt = "item_amt";
    public static final String ISSZMBALV3_t_rm_vip_branch_no = "branch_no";
    public static final String ISSZMBALV3_t_rm_vip_sav_start_date = "sav_start_date";
    public static final String ISSZMBALV3_t_rm_vip_sav_end_date = "sav_end_date";
    public static final String ISSZMBALV3_t_rm_vip_source_card_id = "source_card_id";
    public static final String ISSZMBALV3_t_rm_vip_vip_add1 = "vip_add1";
    public static final String ISSZMBALV3_t_rm_vip_vip_add2 = "vip_add2";
    public static final String ISSZMBALV3_t_rm_vip_annex_property1 = "annex_property1";
    public static final String ISSZMBALV3_t_rm_vip_annex_property2 = "annex_property2";
    public static final String ISSZMBALV3_t_rm_vip_annex_property3 = "annex_property3";
    public static final String ISSZMBALV3_t_rm_vip_annex_property4 = "annex_property4";
    public static final String ISSZMBALV3_t_rm_vip_annex_property5 = "annex_property5";
    public static final String ISSZMBALV3_t_rm_vip_annex_property6 = "annex_property6";
    public static final String ISSZMBALV3_t_rm_vip_annex_property7 = "annex_property7";
    public static final String ISSZMBALV3_t_rm_vip_annex_property8 = "annex_property8";
    public static final String ISSZMBALV3_t_rm_vip_annex_property9 = "annex_property9";
    public static final String ISSZMBALV3_t_rm_vip_annex_property10 = "annex_property10";
    public static final String ISSZMBALV3_t_rm_vip_picture_type = "picture_type";
    public static final String ISSZMBALV3_t_rm_vip_vip_spec_date1 = "vip_spec_date1";
    public static final String ISSZMBALV3_t_rm_vip_vip_spec_date2 = "vip_spec_date2";
    public static final String ISSZMBALV3_t_rm_vip_vip_spec_date3 = "vip_spec_date3";
    public static final String ISSZMBALV3_t_rm_vip_bth_flag = "bth_flag";
    public static final String ISSZMBALV3_t_rm_vip_vip_credentials = "vip_credentials";
    public static final String ISSZMBALV3_t_rm_vip_vip_work = "vip_work";
    public static final String ISSZMBALV3_t_rm_vip_vip_intent = "vip_intent";
    public static final String ISSZMBALV3_t_rm_vip_pur_hobbies = "pur_hobbies";
    public static final String ISSZMBALV3_t_rm_vip_characteristics = "characteristics";
    public static final String ISSZMBALV3_t_rm_vip_vip_trade = "vip_trade";
    public static final String ISSZMBALV3_t_rm_vip_vip_rem = "vip_rem";
    public static final String ISSZMBALV3_t_rm_vip_oper_id_make = "oper_id_make";
    public static final String ISSZMBALV3_t_rm_vip_oper_date_make = "oper_date_make";
    public static final String ISSZMBALV3_t_rm_vip_oper_date_gi = "oper_date_gi";
    public static final String ISSZMBALV3_t_rm_vip_oper_id_gi = "oper_id_gi";
    public static final String ISSZMBALV3_t_rm_vip_is_makecard = "is_makecard";
    public static final String ISSZMBALV3_t_rm_vip_IsAlive = "IsAlive";
    public static final String ISSZMBALV3_t_rm_vip_send_amt = "send_amt";
    public static final String ISSZMBALV3_t_rm_vip_send_start_date = "send_start_date";
    public static final String ISSZMBALV3_t_rm_vip_send_end_date = "send_end_date";
    public static final String ISSZMBALV3_t_rm_vip_openid = "openid";     //如下为思讯8新增字段
    public static final String ISSZMBALV3_t_rm_vip_face_id = "face_id";
    public static final String ISSZMBALV3_t_rm_vip_pay_type = "pay_type";
    public static final String ISSZMBALV3_t_rm_vip_pay_start_date = "pay_start_date";
    public static final String ISSZMBALV3_t_rm_vip_pay_end_date = "pay_end_date";
    public static final String ISSZMBALV3_t_rm_vip_open_pay_date = "open_pay_date";
    public static final String ISSZMBALV3_t_rm_vip_is_taste = "is_taste";
    public static final String ISSZMBALV3_t_rm_vip_taste_times = "taste_times";
    public static final String ISSZMBALV3_t_rm_vip_market_sheet = "market_sheet";
    public static final String ISSZMBALV3_t_rm_vip_wx_face_id = "wx_face_id";
    public static final String ISSZMBALV3_t_rm_vip_ali_face_id = "ali_face_id";
    public static final String ISSZMBALV3_t_rm_vip_face_memo1 = "face_memo1";
    public static final String ISSZMBALV3_t_rm_vip_face_memo2 = "face_memo2";
    public static final String ISSZMBALV3_t_rm_vip_referer_id = "referer_id";

    //Isszmbalv3数据库会员消费目录表(15项)
    public static final String ISSZMBALV3_t_rm_vip_acclist_TABLE_NAME = "t_rm_vip_acclist";
    public static final String ISSZMBALV3_t_rm_vip_acclist_flow_id = "flow_id";
    public static final String ISSZMBALV3_t_rm_vip_acclist_card_id= "card_id";
    public static final String ISSZMBALV3_t_rm_vip_acclist_card_no = "card_no";
    public static final String ISSZMBALV3_t_rm_vip_acclist_card_type = "card_type";
    public static final String ISSZMBALV3_t_rm_vip_acclist_branch_no = "branch_no";
    public static final String ISSZMBALV3_t_rm_vip_acclist_oper_type = "oper_type";
    public static final String ISSZMBALV3_t_rm_vip_acclist_oper_id = "oper_id";
    public static final String ISSZMBALV3_t_rm_vip_acclist_ope_date = "ope_date";
    public static final String ISSZMBALV3_t_rm_vip_acclist_flow_no = "flow_no";
    public static final String ISSZMBALV3_t_rm_vip_acclist_consum_amt = "consum_amt";
    public static final String ISSZMBALV3_t_rm_vip_acclist_acc_num = "acc_num";
    public static final String ISSZMBALV3_t_rm_vip_acclist_new_cardno = "new_cardno";
    public static final String ISSZMBALV3_t_rm_vip_acclist_oper_des = "oper_des";
    public static final String ISSZMBALV3_t_rm_vip_acclist_memo = "memo";
    public static final String ISSZMBALV3_t_rm_vip_acclist_com_flag = "com_flag";

    //Isszmbalv3供应商信息
    public static final String ISSZMBALV3_t_bd_supcust_info_TABLE_NAME = "t_bd_supcust_info";
    public static final String ISSZMBALV3_t_bd_supcust_info_supcust_no = "supcust_no";
    public static final String ISSZMBALV3_t_bd_supcust_info_sup_name = "sup_name";
    public static final String ISSZMBALV3_t_bd_supcust_info_sup_type = "sup_type";
    public static final String ISSZMBALV3_t_bd_supcust_info_supcust_flag = "supcust_flag";

    //Isszmbalv3门店信息
    public static final String ISSZMBALV3_BRANCH_INFO_TABLE_NAME = "t_bd_branch_info";
    public static final String ISSZMBALV3_BRANCH_INFO_BRANCH_NO = "branch_no";
    public static final String ISSZMBALV3_BRANCH_INFO_BRANCH_NAME = "branch_name";
    public static final String ISSZMBALV3_BRANCH_INFO_PROPERTY = "property";

    //Isszmbalv3数据库营收报表
    public static final String ISSZMBALV3_PAY_FLOW_TABLE_NAME = "t_rm_payflow";
    public static final String ISSZMBALV3_PAY_FLOW_FLOW_NO = "flow_no";
    public static final String ISSZMBALV3_PAY_FLOW_OPERDATE = "oper_date";
    public static final String ISSZMBALV3_PAY_FLOW_SALE_AMOUNT = "sale_amount";
    public static final String ISSZMBALV3_PAY_FLOW_PAY_AMOUNT = "pay_amount";
    public static final String ISSZMBALV3_PAY_FLOW_PAY_WAY = "pay_way";
    public static final String ISSZMBALV3_PAY_FLOW_RDM_NO = "rdm_no";
    public static final String ISSZMBALV3_PAY_FLOW_CARD_ID = "card_id";

    //Isszmbalv3数据库营收报表
    public static final String ISSZMBALV3_SALE_FLOW_TABLE_NAME = "t_rm_saleflow";
    public static final String ISSZMBALV3_SALE_FLOW_FLOW_NO = "flow_no";
    public static final String ISSZMBALV3_SALE_FLOW_OPERDATE = "oper_date";
    public static final String ISSZMBALV3_SALE_FLOW_ITEM_NO = "item_no";
    public static final String ISSZMBALV3_SALE_FLOW_SOURCE_PRICE = "source_price";
    public static final String ISSZMBALV3_SALE_FLOW_COST_PRICE = "cost_price";
    public static final String ISSZMBALV3_SALE_FLOW_SALE_QNTY = "sale_qnty";
    public static final String ISSZMBALV3_SALE_FLOW_SALE_MONER= "sale_money";
    public static final String ISSZMBALV3_SALE__FLOW_CARD_ID = "card_id";

    //Isszmbalv3商品类型
    public static final String ISSZMBALV3_ITEM_CLS_TABLE_NAME = "t_bd_item_cls";
    public static final String ISSZMBALV3_ITEM_CLS_ITEM_CLSNO = "item_clsno";
    public static final String ISSZMBALV3_ITEM_CLS_ITEM_CLSNAME = "item_clsname";


    //本地存取数据库，用于保存isszmbalv3商品类目主键
    public static final String LOCAL_ISSZMBALV3_ITEM_CLS_TABLE_NAME_PRIMARY = "itemclsprimary";

    //本地存取数据库，用于保存isszmbalv3商品
    public static final String LOCAL_ISSZMBALV3_t_bd_item_info_TABLE_NAME_PRIMARY = "iteminfoprimary";

    //本地存取数据库，用于保存isszmbalv3会员
    public static final String LOCAL_ISSZMBALV3_t_rm_vip_info_TABLE_NAME_PRIMARY = "vipinfoprimary";

    //本地存取数据库，用于保存isszmbalv3门店信息表主键
    public static final String  ISSZMBALV3_BRANCH_INFO_TABLE_NAME_PRIMARY = "branchinfoprimary";

    //本地存取数据库，用于保存isszmbalv3供应商信息表主键
    public static final String  ISSZMBALV3_t_bd_supcust_info_TABLE_NAME_PRIMARY = "supcustinfoprimary";

    //本地存取数据库，用于保存isszmbalv3销售额表主键
    public static final String ISSZMBALV3_PAY_FLOW_TABLE_NAME_PRIMARY = "payflowprimary";

    //本地存取数据库，用于保存isszmbalv3销售详情主键
    public static final String ISSZMBALV3_SALE_FLOW_TABLE_NAME_PRIMARY = "saleflowprimary";

    //创建历史输入表
    public static final String INPUT_HISTORY_TABLE_NAME = "history";
    public static final String INPUT_HISTORY_TABLE_NAME_PRIMARY = "historyprimary";
    public static final String INPUT_HISTORY_NAME = "history_name";


    /**
     * 访问SQL Lite fastfood数据库
     *
     * @author taoli
     * @since 2015-0-10 下午04:57:36
     */
    public static List<StockInfo> getStockInfoListFromLocal(Context context, int startIndex, int pagesize, int readMode, int sortMode, String searchStr) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<StockInfo> result = new ArrayList<StockInfo>();
        Cursor cursor = null;
        switch (readMode) {
            case 0:// By all
                cursor = localDatabaseHelper.getAll(startIndex, pagesize, sortMode);
                break;
            case 1:// By stockid
                cursor = localDatabaseHelper.getById(searchStr, startIndex, pagesize, sortMode);
                break;
            case 2://By stockname
                cursor = localDatabaseHelper.getByName(searchStr, startIndex, pagesize, sortMode);
                break;
            case 3://By stockspell
                cursor = localDatabaseHelper.getBySpell(searchStr, startIndex, pagesize, sortMode);
                break;
            case 4://By stockbracode
                cursor = localDatabaseHelper.getByBarcode(searchStr, startIndex, pagesize, sortMode);
                break;
            case 5:// By stockid
                cursor = localDatabaseHelper.getById1(searchStr);
                break;
            case 6://By stocktype
                if (searchStr.equals("-1"))
                    cursor = localDatabaseHelper.getAll(startIndex, pagesize, sortMode);
                else
                    cursor = localDatabaseHelper.getByTypeId(searchStr, startIndex, pagesize, sortMode);
                break;
        }

        if (cursor == null)
            return result;

        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToFirst();
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                StockInfo stockInfo = new StockInfo();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.STOCK_STOCKID);
                stockInfo.stockId = cursor.getString(columnIndex).trim();
                columnIndex = cursor.getColumnIndex(DatabaseManager.STOCK_STOCKNAME);
                stockInfo.stockName = cursor.getString(columnIndex).trim();
                columnIndex = cursor.getColumnIndex(DatabaseManager.STOCK_SPELL);
                stockInfo.stockSpell = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.STOCK_TYPEID);
                stockInfo.stockTpyeId = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.STOCK_COST);
                stockInfo.stockCost = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.STOCK_RETAIL_PRICE);
                stockInfo.stockDetailPrice = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.STOCK_MEMBER_PRICE);
                stockInfo.stockMemberPrice = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.STOCK_BARCODE);
                stockInfo.stockBarcode = cursor.getString(columnIndex);

                //从某种编码的数据库中独处的Blob字节需要编码成java String
                //columnIndex = cursor.getColumnIndex(STOCK_TYPEID);
                //stockInfo.stockTpyeId = cursor.getString(columnIndex);//new String(cursor.getBlob(columnIndex), "gb2312");
                result.add(stockInfo);
            }
        }
        cursor.close();
        return result;
    }

    public static Map<String, String> getStockTypeListFromLocal(Context context) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        Map<String, String> stockTypeMap = new TreeMap<String, String>();
        try {
            Cursor cursor = localDatabaseHelper.getAllStockType();
            int resultCount = cursor.getCount();
            if (resultCount > 0) {
                cursor.moveToPosition(0);
                for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                    int columnIndex = cursor.getColumnIndex(STOCK_TYPE_TYPEID);
                    String typeId = cursor.getString(columnIndex);
                    String typeName = null;
                    try {
                        columnIndex = cursor.getColumnIndex(STOCK_TYPE_TYPENAME);
                        typeName = cursor.getString(columnIndex);
                        //从某种编码的数据库中独处的Blob字节需要编码成java String
                        //typeName = new String(cursor.getBlob(columnIndex), "gb2312");
                    } catch (Exception e) {
                        typeName = "";
                    }
                    stockTypeMap.put(typeId, typeName);
                }
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return stockTypeMap;
    }

    public static long deleteStockInfoFromLocal(Context context, String stockId) {
        long row = -1;
        try {
            LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
            row = localDatabaseHelper.deleteStock(stockId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<Member> getMemberInfoListFromLocal(Context context, int startIndex, int pagesize, int readMode, int sortMode, String searchStr) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<Member> result = new ArrayList<Member>();
        Cursor cursor = null;
        try {
            switch (readMode) {
                case 0:// By all
                    cursor = localDatabaseHelper.getAllMember(startIndex, pagesize, searchStr, sortMode);
                    break;
                case 1:// By id
                    cursor = localDatabaseHelper.getByMemberId(searchStr, sortMode);
                    break;
                case 2:// By name
                    cursor = localDatabaseHelper.getByMemberName(searchStr, sortMode);
                    break;
                case 3:// By mobile
                    cursor = localDatabaseHelper.getByMemberMobile(searchStr, sortMode);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (cursor == null)
            return result;

        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToPosition(0);
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                Member memberInfo = new Member();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.MEMBER_MEMBERID);
                memberInfo.memberId = cursor.getString(columnIndex).trim();
                columnIndex = cursor.getColumnIndex(DatabaseManager.MEMBER_NAME);
                memberInfo.memberName = cursor.getString(columnIndex).trim();
                columnIndex = cursor.getColumnIndex(DatabaseManager.MEMBER_SEX);
                memberInfo.memberSex = cursor.getString(columnIndex).trim();
                columnIndex = cursor.getColumnIndex(DatabaseManager.MEMBER_MOBILE);
                memberInfo.memberMobile = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.MEMBER_POINT);
                memberInfo.memberPoint = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.MEMBER_MEMBERTYPE);
                memberInfo.memberType = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.MEMBER_CARDID);
                memberInfo.memberCardid = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.MEMBER_MODIFY_SN);
                memberInfo.memberModifySn = cursor.getInt(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.MEMBER_TOTAL_CONSUME);
                memberInfo.memberTotalConsume = cursor.getFloat(columnIndex);
                String str = "#";
                if (memberInfo.memberName.length() != 0)
                    str = Utils.cn2FirstSpell(memberInfo.memberName).substring(0, 1);
                if (str.matches("[A-Z]")) {
                    memberInfo.setSortLetters(str);
                } else {
                    memberInfo.setSortLetters("#");
                }
                result.add(memberInfo);
            }
        }
        cursor.close();
        return result;
    }

    public static long deleteMemberInfoFromLocal(Context context, String memberId) {
        long row = -1;
        try {
            LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
            row = localDatabaseHelper.deleteMember(memberId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<PayMaster> getPayMasterInfoListFromLocal(Context context, int readMode, String searchStr) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<PayMaster> result = new ArrayList<PayMaster>();
        Cursor cursor = null;
        try {
            switch (readMode) {
                case 1:// By date
                    cursor = localDatabaseHelper.getByPayMasterOperdate(searchStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (cursor == null)
            return result;

        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToPosition(0);
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                PayMaster payMasterInfo = new PayMaster();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.PAY_MASTER_BILLNO);
                payMasterInfo.payMasterBillno = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.PAY_MASTER_OPERDATE);
                String datatime = cursor.getString(columnIndex);
                try {
                    Date date = dateformat.parse(datatime);
                    payMasterInfo.payMasterOperdate = new java.sql.Date(date.getTime());
                    payMasterInfo.payMasterOpertime = new java.sql.Time(date.getTime());
                }catch(Exception e){
                    e.printStackTrace();
                }
                columnIndex = cursor.getColumnIndex(DatabaseManager.PAY_MASTER_BLOTOUT);
                payMasterInfo.payMasterBlotout = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.PAY_MASTER_TOTAL);
                payMasterInfo.payMasterTotal = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.PAY_MASTER_RECEIVABLE);
                payMasterInfo.payMasterReceivable = cursor.getFloat(columnIndex);
                result.add(payMasterInfo);
            }
        }
        cursor.close();
        return result;
    }

    public static List<SaleDetailInfo> getSaleDetailInfoFromLocal(Context context, int readMode, String searchStr) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<SaleDetailInfo> result = new ArrayList<SaleDetailInfo>();
        Cursor cursor = null;
        try {
            switch (readMode) {
                case 0:// By billno
                    cursor = localDatabaseHelper.getSaleDetailByBillno(searchStr);
                    break;
                case 1:// By date
                    cursor = localDatabaseHelper.getSaleDetailByDate(searchStr);
                    break;
                case 2:// By stockid
                    cursor = localDatabaseHelper.getSaleDetailByStockid(searchStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (cursor == null)
            return result;

        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToPosition(0);
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                SaleDetailInfo saleDetailInfo = new SaleDetailInfo();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.SALE_DETAIL_BILLNO);
                saleDetailInfo.saleDetailBillno = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.SALE_DETAIL_STOCKID);
                saleDetailInfo.saleDetailStockid = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.SALE_DETAIL_QUANTITY);
                saleDetailInfo.saleDetailQuantity = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.SALE_DETAIL_OPERATEDATE);
                String datatime = cursor.getString(columnIndex);
                try {
                    Date date = dateformat.parse(datatime);
                    saleDetailInfo.saleDetailOperdate = new java.sql.Date(date.getTime());
                    saleDetailInfo.saleDetailOpertime = new java.sql.Time(date.getTime());
                }catch(Exception e){
                    e.printStackTrace();
                }
                columnIndex = cursor.getColumnIndex(DatabaseManager.SALE_DETAIL_PRICE);
                saleDetailInfo.saleDetailPrice = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.SALE_DETAIL_COST);
                saleDetailInfo.saleDetailCost = cursor.getFloat(columnIndex);
                result.add(saleDetailInfo);
            }
        }
        cursor.close();
        return result;
    }




    /**
     * 访问SQL Lite Isszmbalv3数据库
     *
     * @author taoli
     * @since 2015-0-10 下午04:57:36
     */
    public static List<Isszmbalv3StockInfo> getIsszmbalv3StockInfoListFromLocal(Context context, int startIndex, int pagesize, int readMode, int sortMode, String searchStr) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<Isszmbalv3StockInfo> result = new ArrayList<Isszmbalv3StockInfo>();
        Cursor cursor = null;
        switch (readMode) {
            case 0:// By all
                if( searchStr.equals("-1"))
                    cursor = localDatabaseHelper.getAllIsszmbalv3Stock(startIndex, pagesize, sortMode);
                else
                    cursor = localDatabaseHelper.getIsszmbalv3StockByTypeId(searchStr, startIndex, pagesize, sortMode);
                break;
            case 1:// By item_no
                cursor = localDatabaseHelper.getIsszmbalv3StockByNo(searchStr, sortMode);
                break;
            case 2://By stockname
                cursor = localDatabaseHelper.getIsszmbalv3StockByName(searchStr, sortMode);
                break;
            case 3://By stockspell
                cursor = localDatabaseHelper.getIsszmbalv3StockBySpell(searchStr, sortMode);
                break;
            case 4://By item_no
                cursor = localDatabaseHelper.getIsszmbalv3StockByNo1(searchStr);
                break;
        }

        if (cursor == null)
            return result;

        result = getIsszmbalv3StockInfo(cursor);
        return result;
    }

    private static List<Isszmbalv3StockInfo> getIsszmbalv3StockInfo( Cursor cursor ){
        List<Isszmbalv3StockInfo> result = new ArrayList<Isszmbalv3StockInfo>();
        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToFirst();
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                Isszmbalv3StockInfo isszmbalv3StockInfo = new Isszmbalv3StockInfo();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_info_item_no);
                isszmbalv3StockInfo.item_no = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_info_item_name);
                isszmbalv3StockInfo.item_name = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_info_item_subname);
                isszmbalv3StockInfo.item_subname = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_info_item_clsno);
                isszmbalv3StockInfo.item_clsno = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_item_rem);
                isszmbalv3StockInfo.item_rem = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_price);
                isszmbalv3StockInfo.price = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_sale_price);
                isszmbalv3StockInfo.sale_price = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_measure_flag);
                isszmbalv3StockInfo.measure_flag = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_new_oper_id);
                isszmbalv3StockInfo.new_oper_id = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_modify_oper_id);
                isszmbalv3StockInfo.modify_oper_id = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_item_vip_acc_flag);
                isszmbalv3StockInfo.vip_acc_flag = cursor.getString(columnIndex);
                result.add(isszmbalv3StockInfo);
            }
        }
        cursor.close();
        return result;
    }

    public static Map<String, String> getIsszmbalv3StockTypeListFromLocal(Context context) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        Map<String, String> stockTypeMap = new TreeMap<String, String>();
        try {
            Cursor cursor = localDatabaseHelper.getAllIsszmbalv3StockType();
            int resultCount = cursor.getCount();
            if (resultCount > 0) {
                cursor.moveToPosition(0);
                for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                    int columnIndex = cursor.getColumnIndex(ISSZMBALV3_ITEM_CLS_ITEM_CLSNO);
                    String typeId = cursor.getString(columnIndex);
                    String typeName = null;
                    try {
                        columnIndex = cursor.getColumnIndex(ISSZMBALV3_ITEM_CLS_ITEM_CLSNAME);
                        typeName = cursor.getString(columnIndex);
                        //从某种编码的数据库中独处的Blob字节需要编码成java String
                        //typeName = new String(cursor.getBlob(columnIndex), "gb2312");
                    } catch (Exception e) {
                        typeName = "";
                    }
                    stockTypeMap.put(typeId, typeName);
                }
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return stockTypeMap;
    }

    public static long deleteIsszmbalv3StockInfoFromLocal(Context context, String stockno) {
        long row = -1;
        try {
            LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
            row = localDatabaseHelper.deleteIsszmbalv3Stock(stockno);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<Isszmbalv3Member> getIsszmbalv3MemberInfoListFromLocal(Context context, int startIndex, int pagesize, int readMode, int sortMode,  String searchStr) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<Isszmbalv3Member> result = new ArrayList<Isszmbalv3Member>();
        Cursor cursor = null;
        try {
            switch (readMode) {
                case 0:// By all
                    cursor = localDatabaseHelper.getAllIsszmbalv3Member(startIndex, pagesize, searchStr, sortMode);
                    break;
                case 1:// By cardNo
                    cursor = localDatabaseHelper.getByIsszmbalv3MemberCardNo(searchStr, sortMode);
                    break;
                case 2:// By name
                    cursor = localDatabaseHelper.getByIsszmbalv3MemberName(searchStr, sortMode);
                    break;
                case 3:// By mobile
                    cursor = localDatabaseHelper.getByIsszmbalv3MemberMobile(searchStr, sortMode);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (cursor == null)
            return result;

        result = getIsszmbalv3MemberInfo(cursor);

        cursor.close();
        return result;
    }

    private static List<Isszmbalv3Member> getIsszmbalv3MemberInfo( Cursor cursor ){
        List<Isszmbalv3Member> result = new ArrayList<Isszmbalv3Member>();
        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToPosition(0);
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                Isszmbalv3Member isszmbalv3MemberInfo = new Isszmbalv3Member();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_card_type);
                isszmbalv3MemberInfo.memberCardType = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_card_id);
                isszmbalv3MemberInfo.memberCardId = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_card_no);
                isszmbalv3MemberInfo.memberCardNo = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_vip_name);
                isszmbalv3MemberInfo.memberName = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_vip_sex);
                isszmbalv3MemberInfo.memberSex = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_vip_tel);
                isszmbalv3MemberInfo.memberTel = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_vip_email);
                isszmbalv3MemberInfo.memberEmail = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_mobile);
                isszmbalv3MemberInfo.memberMobile = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_consum_count);
                isszmbalv3MemberInfo.memberConsumCount = cursor.getInt(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_consum_amt);
                isszmbalv3MemberInfo.memberConsumAmt = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_acc_num);
                isszmbalv3MemberInfo.memberAccNum = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_dec_num);
                isszmbalv3MemberInfo.memberDecNum = cursor.getFloat(columnIndex);

                try {
                    columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_vip_start_date);
                    String datatime1 = cursor.getString(columnIndex);
                    Date date1 = dateformat.parse(datatime1);
                    isszmbalv3MemberInfo.memberVipStartDay = new java.sql.Date(date1.getTime());
                    //isszmbalv3MemberInfo.memberVipStartDay= new java.sql.Time(date1.getTime());

                    columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_vip_end_date);
                    String datatime2 = cursor.getString(columnIndex);
                    Date date2 = dateformat.parse(datatime2);
                    isszmbalv3MemberInfo.memberVipEndDay = new java.sql.Date(date2.getTime());

                    columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_sav_start_date);
                    String datatime3 = cursor.getString(columnIndex);
                    Date date3 = dateformat.parse(datatime3);
                    isszmbalv3MemberInfo.memberSavStartDay = new java.sql.Date(date3.getTime());

                    columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_rm_vip_sav_end_date);
                    String datatime4 = cursor.getString(columnIndex);
                    Date date4 = dateformat.parse(datatime4);
                    isszmbalv3MemberInfo.memberSavEndDay = new java.sql.Date(date4.getTime());
                }catch(Exception e){
                    e.printStackTrace();
                }

                String str = "#";
                if (isszmbalv3MemberInfo.memberName.length() != 0)
                    str = Utils.cn2FirstSpell(isszmbalv3MemberInfo.memberName).substring(0, 1);
                if (str.matches("[A-Z]")) {
                    isszmbalv3MemberInfo.setSortLetters(str);
                } else {
                    isszmbalv3MemberInfo.setSortLetters("#");
                }
                result.add(isszmbalv3MemberInfo);
            }
        }
        return result;
    }

    public static long deleteIsszmbalv3MemberInfoFromLocal(Context context, String memberId) {
        long row = -1;
        try {
            LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
            row = localDatabaseHelper.deleteIsszmbalv3Member(memberId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<Isszmbalv3BranchInfo> getIsszmbalv3BranchInfoListFromLocal(Context context) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<Isszmbalv3BranchInfo> result = new ArrayList<Isszmbalv3BranchInfo>();
        Cursor cursor = null;
        try {
            cursor = localDatabaseHelper.getIsszmbalv3BranchInfo();
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (cursor == null)
            return result;

        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToPosition(0);
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                Isszmbalv3BranchInfo isszmbalv3BranchInfo = new Isszmbalv3BranchInfo();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_BRANCH_INFO_BRANCH_NO);
                isszmbalv3BranchInfo.no = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_BRANCH_INFO_BRANCH_NAME);
                isszmbalv3BranchInfo.name = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_BRANCH_INFO_PROPERTY);
                isszmbalv3BranchInfo.property = cursor.getString(columnIndex);
                result.add(isszmbalv3BranchInfo);
            }
        }
        cursor.close();
        return result;
    }

    public static List<Isszmbalv3SupcustInfo> getIsszmbalv3SupcustInfoListFromLocal(Context context) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<Isszmbalv3SupcustInfo> result = new ArrayList<Isszmbalv3SupcustInfo>();
        Cursor cursor = null;
        try {
            cursor = localDatabaseHelper.getIsszmbalv3SupcustInfo();
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (cursor == null)
            return result;

        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToPosition(0);
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                Isszmbalv3SupcustInfo isszmbalv3SupcustInfo = new Isszmbalv3SupcustInfo();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_supcust_info_supcust_no);
                isszmbalv3SupcustInfo.supcust_no = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_supcust_info_sup_name);
                isszmbalv3SupcustInfo.sup_name = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_t_bd_supcust_info_sup_type);
                isszmbalv3SupcustInfo.sup_type = cursor.getString(columnIndex);
                result.add(isszmbalv3SupcustInfo);
            }
        }
        cursor.close();
        return result;
    }

    public static List<Isszmbalv3PayFlow> getIsszmbalv3PayFlowInfoListFromLocal(Context context, int readMode, String searchDateStr, String searchBranchNoStr) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<Isszmbalv3PayFlow> result = new ArrayList<Isszmbalv3PayFlow>();
        Cursor cursor = null;
        try {
            switch (readMode) {
                case 1:// By date
                    cursor = localDatabaseHelper.getIsszmbalv3PayFlowByOperdate(searchDateStr, searchBranchNoStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (cursor == null)
            return result;

        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToPosition(0);
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                Isszmbalv3PayFlow isszmbalv3PayFlowInfo = new Isszmbalv3PayFlow();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_PAY_FLOW_FLOW_NO);
                isszmbalv3PayFlowInfo.payFlowFlow_no = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_PAY_FLOW_OPERDATE);
                String datatime = cursor.getString(columnIndex);
                try {
                    Date date = dateformat.parse(datatime);
                    isszmbalv3PayFlowInfo.payFlowOperdate = new java.sql.Date(date.getTime());
                    isszmbalv3PayFlowInfo.payFlowOpertime = new java.sql.Time(date.getTime());
                }catch(Exception e){
                    e.printStackTrace();
                }
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_PAY_FLOW_SALE_AMOUNT);
                isszmbalv3PayFlowInfo.payFlowSale_amount = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_PAY_FLOW_PAY_AMOUNT);
                isszmbalv3PayFlowInfo.payFlowPay_amount = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_PAY_FLOW_PAY_WAY);
                isszmbalv3PayFlowInfo.payFlowPay_way = cursor.getString(columnIndex);
                result.add(isszmbalv3PayFlowInfo);
            }
        }
        cursor.close();
        return result;
    }

    public static List<Isszmbalv3SaleDetailInfo> getIsszmbalv3SaleDetailInfoFromLocal(Context context, int readMode, String searchDateStr, String searchBranchNoStr) {
        LocalDatabaseHelper localDatabaseHelper = LocalDatabaseHelper.getInstance(context);
        List<Isszmbalv3SaleDetailInfo> result = new ArrayList<Isszmbalv3SaleDetailInfo>();
        Cursor cursor = null;
        try {
            switch (readMode) {
                case 0:// By flowno
                    cursor = localDatabaseHelper.getIsszmbalv3SaleDetailByFlowno(searchDateStr, searchBranchNoStr);
                    break;
                case 1:// By date
                    cursor = localDatabaseHelper.getIsszmbalv3SaleDetailByDate(searchDateStr, searchBranchNoStr);
                    break;
                case 2:// By stockno
                    cursor = localDatabaseHelper.getIsszmbalv3SaleDetailByStockno(searchDateStr, searchBranchNoStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (cursor == null)
            return result;

        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        int resultCount = cursor.getCount();
        if (resultCount > 0) {
            cursor.moveToPosition(0);
            for (; !cursor.isAfterLast(); cursor.moveToNext()) {
                Isszmbalv3SaleDetailInfo isszmbalv3SaleDetailInfo = new Isszmbalv3SaleDetailInfo();
                int columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_SALE_FLOW_FLOW_NO);
                isszmbalv3SaleDetailInfo.saleDetailflow_no = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_SALE_FLOW_ITEM_NO);
                isszmbalv3SaleDetailInfo.saleDetailitem_no = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_SALE_FLOW_SOURCE_PRICE);
                isszmbalv3SaleDetailInfo.saleDetailPrice = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_SALE_FLOW_OPERDATE);
                String datatime = cursor.getString(columnIndex);
                try {
                    Date date = dateformat.parse(datatime);
                    isszmbalv3SaleDetailInfo.saleDetailOperdate = new java.sql.Date(date.getTime());
                    isszmbalv3SaleDetailInfo.saleDetailOpertime = new java.sql.Time(date.getTime());
                }catch(Exception e){
                    e.printStackTrace();
                }
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_SALE_FLOW_COST_PRICE);
                isszmbalv3SaleDetailInfo.saleDetailCost = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_SALE_FLOW_SALE_QNTY);
                isszmbalv3SaleDetailInfo.saleDetailQuantity = cursor.getFloat(columnIndex);
                columnIndex = cursor.getColumnIndex(DatabaseManager.ISSZMBALV3_SALE_FLOW_SALE_MONER);
                isszmbalv3SaleDetailInfo.saleDetailSaleMonery = cursor.getFloat(columnIndex);
                result.add(isszmbalv3SaleDetailInfo);
            }
        }
        cursor.close();
        return result;
    }



    /**
     * 访问Microsoft SQL Server fastfood数据库
     *
     * @author taoli
     * @since 2015-0-10 下午04:57:36
     */
    public static int getStockCountFromSqlServer(Context context, String stockTypeId) {
        int count = -1;
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        try {
            count = sQLServerHelper.getStockCount(stockTypeId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return count;
    }

    public static String getStockMaxIndexFromSqlServer(Context context, long size) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        long maxIndex = -1;
        try {
            maxIndex = sQLServerHelper.searchById(size);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return String.valueOf(maxIndex);
    }

    public static List<StockInfo> getStockInfoListFromSqlServer(Context context, int startIndex, int pagesize, int maxCount, int readMode, int sortMode, String searchStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<StockInfo> result = new ArrayList<StockInfo>();
        try {
            switch (readMode) {
                case 0:// By all
                    result = sQLServerHelper.getAll(startIndex, pagesize, maxCount, sortMode);
                    break;
                case 1:// By stockid
                    result = sQLServerHelper.getById(searchStr, sortMode);
                    break;
                case 2://By stockname
                    result = sQLServerHelper.getByName(searchStr, sortMode);
                    break;
                case 3://By stockspell
                    result = sQLServerHelper.getBySpell(searchStr, sortMode);
                    break;
                case 4://By stockbracode
                    result = sQLServerHelper.getByBarcode(searchStr, sortMode);
                    break;
                case 5:// By stockid
                    result = sQLServerHelper.getById1(searchStr);
                    break;
                case 6:// By stocktype
                    if (searchStr.equals("-1"))
                        result = sQLServerHelper.getAll(startIndex, pagesize, maxCount, sortMode);
                    else
                        result = sQLServerHelper.getByTypeId(searchStr, startIndex, pagesize, maxCount, sortMode);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

    public static long insertStockInfoFromSqlServer(Context context, List<ContentValues> initialValuesList) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.insert(initialValuesList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long replaceStockInfoFromSqlServer(Context context, ContentValues initialValues) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.replace(initialValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long deleteStockInfoFromSqlServer(Context context, String stockId) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.delete(stockId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static Map<String, String> getStockTypeListFromSqlServer(Context context) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        Map<String, String> stockTypeMap = null;
        try {
            stockTypeMap = sQLServerHelper.getAllStockType();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return stockTypeMap;
    }


    public static int getMemberCountFromSqlServer(Context context, String searchStr) {
        int count = -1;
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        try {
            count = sQLServerHelper.getMemberCount(searchStr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return count;
    }

    public static List<Member> getMemberInfoListFromSqlServer(Context context, int startIndex, int pagesize, int maxCount, int readMode, int sortMode, String searchStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<Member> result = new ArrayList<Member>();
        try {
            switch (readMode) {
                case 0:// By all
                    result = sQLServerHelper.getAllMember(startIndex, pagesize, maxCount, searchStr, sortMode);
                    break;
                case 1:// By id
                    result = sQLServerHelper.getByMemberId(searchStr, sortMode);
                    break;
                case 2:// By name
                    result = sQLServerHelper.getByMemberName(searchStr, sortMode);
                    break;
                case 3:// By mobile
                    result = sQLServerHelper.getByMemberMobile(searchStr, sortMode);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

    public static long deleteMemberInfoFromSqlServer(Context context, String memberId) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.deleteMember(memberId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long insertMemberInfoFromSqlServer(Context context, ContentValues initialValues) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.insertMember(initialValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long replaceMemberInfoFromSqlServer(Context context, ContentValues initialValues) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.replaceMember(initialValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<PayMaster> getPayMasterInfoListFromSqlServer(Context context, int readMode, String searchStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<PayMaster> result = new ArrayList<PayMaster>();
        try {
            switch (readMode) {
                case 1:// By date
                    result = sQLServerHelper.getByPayMasterOperdate(searchStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

    public static long deletePayMasterInfoFromSqlServer(Context context, String deleteDate) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.deletePayMaster(deleteDate);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<SaleDetailInfo> getSaleDetailInfoFromSqlServer(Context context, int readMode, String searchStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<SaleDetailInfo> result = new ArrayList<SaleDetailInfo>();
        try {
            switch (readMode) {
                case 0:// By billno
                    result = sQLServerHelper.getSaleDetailByBillno(searchStr);
                    break;
                case 1:// By date
                    result = sQLServerHelper.getSaleDetailByDate(searchStr);
                    break;
                case 2:// By stockid
                    result = sQLServerHelper.getSaleDetailByStockid(searchStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public static List<MemberPointInfo> getMemberPointInfoFromSqlServer(Context context, int readMode, String searchStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<MemberPointInfo> result = new ArrayList<MemberPointInfo>();
        try {
            switch (readMode) {
                case 0:// By all
                    result = sQLServerHelper.getMemberPointByMemberId(searchStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }











    /**
     * 访问Microsoft SQL Server Isszmbalv3数据库
     *
     * @author taoli
     * @since 2015-0-10 下午04:57:36
     */
    public static List<Isszmbalv3SupcustInfo> getIsszmbalv3SupcustInfoListFromSqlServer(Context context) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<Isszmbalv3SupcustInfo> isszmbalv3SupcustInfoList = null;
        try {
            isszmbalv3SupcustInfoList = sQLServerHelper.getIsszmbalv3SupcustInfoList();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return isszmbalv3SupcustInfoList;
    }

    public static long insertIsszmbalv3SupcustInfo(Context context, ContentValues initialValues) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.insertIsszmbalv3SupcustInfo(initialValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long updateIsszmbalv3SupcustInfo(Context context, ContentValues initialValues) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.updateIsszmbalv3SupcustInfo(initialValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static Map<String, String> getIsszmbalv3StockTypeListFromSqlServer(Context context) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        Map<String, String> isszmbalv3StockTypeMap = null;
        try {
            isszmbalv3StockTypeMap = sQLServerHelper.getIsszmbalv3AllStockType();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return isszmbalv3StockTypeMap;
    }

    public static String getIsszmbalv3MaxDispersionIndex(Context context ) {
        String index = "";
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        try {
            index = sQLServerHelper.getIsszmbalv3MaxDispersionIndex();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return index;
    }

    public static int getIsszmbalv3StockCountFromSqlServer(Context context ,String typeid) {
        int count = -1;
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        try {
            count = sQLServerHelper.getIsszmbalv3StockCount(typeid);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return count;
    }

    public static List<Isszmbalv3StockInfo> getIsszmbalv3StockInfoListFromSqlServer(Context context, int startIndex, int pagesize, int maxCount, int readMode, int sortMode, String searchStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<Isszmbalv3StockInfo> result = new ArrayList<Isszmbalv3StockInfo>();
        try {
            switch (readMode) {
                case 0:// By all
                    if( searchStr.equals("-1"))
                        result = sQLServerHelper.getAllIsszmbalv3Stock(startIndex, pagesize, maxCount, sortMode);
                    else
                        result = sQLServerHelper.getIsszmbalv3StockByTypeId(searchStr, startIndex, pagesize, maxCount, sortMode);
                    break;
                case 1:// By item_no
                    result = sQLServerHelper.getIsszmbalv3StockByNo(searchStr, sortMode);
                    break;
                case 2://By stockname
                    result = sQLServerHelper.getIsszmbalv3StockByName(searchStr, sortMode);
                    break;
                case 3://By stockspell
                    result = sQLServerHelper.getIsszmbalv3StockBySpell(searchStr, sortMode);
                    break;
                case 4:// By item_no
                    result = sQLServerHelper.getIsszmbalv3StockByNo1(searchStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

    public static long insertIsszmbalv3StockInfoFromSqlServer(Context context, ContentValues initialValues) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.insertIsszmbalv3StockInfo(initialValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long replaceIsszmbalv3StockInfoFromSqlServer(Context context, ContentValues initialValues) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.replaceIsszmbalv3StockInfo(initialValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long deleteIsszmbalv3StockInfoFromSqlServer(Context context, String stockNo) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.deleteIsszmbalv3StockInfo(stockNo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<Isszmbalv3BranchInfo> getIsszmbalv3BranchInfoListFromSqlServer(Context context) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<Isszmbalv3BranchInfo> result = new ArrayList<Isszmbalv3BranchInfo>();
        try {
            result = sQLServerHelper.getIsszmbalv3BranchInfo();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public static List<Isszmbalv3PayFlow> getIsszmbalv3PayFlowInfoListFromSqlServer(Context context, int readMode, String searchDateStr, String searchBranchNoStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<Isszmbalv3PayFlow> result = new ArrayList<Isszmbalv3PayFlow>();
        try {
            switch (readMode) {
                case 1:// By date
                    result = sQLServerHelper.getIsszmbalv3PayFlowByOperdate(searchDateStr,searchBranchNoStr);
                    break;

            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

    public static long deleteIsszmbalv3PayFlowInfoFromSqlServer(Context context, String deleteDate) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.deleteIsszmbalv3PayFlowByOperdate(deleteDate);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<Isszmbalv3SaleDetailInfo> getIsszmbalv3SaleDetailInfoFromSqlServer(Context context, int readMode,String searchDateStr, String searchBranchNoStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<Isszmbalv3SaleDetailInfo> result = new ArrayList<Isszmbalv3SaleDetailInfo>();
        try {
            switch (readMode) {
                case 0:// By flow_no
                    result = sQLServerHelper.getIsszmbalv3SaleDetailByFlowno(searchDateStr, searchBranchNoStr);
                    break;
                case 1:// By date
                    result = sQLServerHelper.getIsszmbalv3SaleDetailByDate(searchDateStr, searchBranchNoStr);
                    break;
                case 2:// By item_no
                    result = sQLServerHelper.getIsszmbalv3SaleDetailByItemno(searchDateStr, searchBranchNoStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public static int getIsszmbalv3MemberCountFromSqlServer(Context context, String searchStr) {
        int count = -1;
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        try {
            count = sQLServerHelper.getIsszmbalv3MemberCount(searchStr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return count;
    }

    public static List<Isszmbalv3Member> getIsszmbalv3MemberInfoListFromSqlServer(Context context, int startIndex, int pagesize, int maxCount, int readMode, int sortMode, String searchStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<Isszmbalv3Member> result = new ArrayList<Isszmbalv3Member>();
        try {
            switch (readMode) {
                case 0:// By all
                    result = sQLServerHelper.getAllIsszmbalv3Member(startIndex, pagesize, maxCount, searchStr, sortMode);
                    break;
                case 1:// By cardNo
                    result = sQLServerHelper.getByIsszmbalv3MemberCardNo(searchStr, sortMode);
                    break;
                case 2:// By name
                    result = sQLServerHelper.getByIsszmbalv3MemberName(searchStr, sortMode);
                    break;
                case 3:// By mobile
                    result = sQLServerHelper.getByIsszmbalv3MemberMobile(searchStr, sortMode);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

    public static long deleteIsszmbalv3MemberInfoFromSqlServer(Context context, String memberCardId) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.deleteIsszmbalv3Member(memberCardId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long insertIsszmbalv3MemberInfoFromSqlServer(Context context, ContentValues initialValues) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.insertIsszmbalv3Member(initialValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long replaceIsszmbalv3MemberInfoFromSqlServer(Context context, ContentValues initialValues) {
        long row = -1;
        try {
            MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
            row = sQLServerHelper.replaceIsszmbalv3Member(initialValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<Isszmbalv3MemberPointInfo> getIsszmbalv3MemberPointInfoFromSqlServer(Context context, int readMode, String searchStr) {
        MicrosoftSQLServerHelper sQLServerHelper = MicrosoftSQLServerHelper.getInstance(context);
        List<Isszmbalv3MemberPointInfo> result = new ArrayList<Isszmbalv3MemberPointInfo>();
        try {
            switch (readMode) {
                case 0:// By all
                    result = sQLServerHelper.getIsszmbalv3MemberPointByMemberId(searchStr);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }



    /**
     * 本地数据库思讯历史商品会员数据的存取
     *
     * @author taoli
     * @since 2015-0-10 下午04:57:36
     */
    public static long insertIsszmbalv3MemberInfoFromHistory(Context context, ContentValues initialValuesList) {
        long row = -1;
        try {
            HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
            localDatabaseHelper.deleteIsszmbalv3Member(initialValuesList);
            row = localDatabaseHelper.insertIsszmbalv3Member(initialValuesList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<Isszmbalv3Member> getIsszmbalv3MemberInfoListFromHistory(Context context) {
        HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
        List<Isszmbalv3Member> result =  new ArrayList<Isszmbalv3Member>();
        Cursor cursor = localDatabaseHelper.getAllIsszmbalv3Member();
        if (cursor == null)
            return result;
        result = getIsszmbalv3MemberInfo(cursor);
        cursor.close();
        return result;
    }

    public static long insertIsszmbalv3StockInfoFromHistory(Context context, List<ContentValues> initialValuesList) {
        long row = -1;
        try {
            HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
            localDatabaseHelper.deleteIsszmbalv3Stock(initialValuesList);
            row = localDatabaseHelper.insertIsszmbalv3Stock(initialValuesList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static long insertIsszmbalv3StockInfoFromHistory(Context context, ContentValues initialValuesList) {
        long row = -1;
        try {
            HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
            localDatabaseHelper.deleteIsszmbalv3Stock(initialValuesList);
            row = localDatabaseHelper.insertIsszmbalv3Stock(initialValuesList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<Isszmbalv3StockInfo> getIsszmbalv3StockInfoListFromHistory(Context context) {
        HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
        List<Isszmbalv3StockInfo> result = new ArrayList<Isszmbalv3StockInfo>();
        Cursor cursor = localDatabaseHelper.getAllIsszmbalv3Stock();
        if (cursor == null)
            return result;
        result = getIsszmbalv3StockInfo(cursor);
        cursor.close();
        return result;
    }

    public static void deleteAllIsszmbalv3StockInfoFromHistory(Context context) {
        HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
        localDatabaseHelper.deleteAllIsszmbalv3Stocks();
    }

    public static long deleteIsszmbalv3StockInfoFromHistory(Context context, String stockno) {
        long row = -1;
        try {
            HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
            ContentValues deleteValues = new ContentValues();
            deleteValues.put(DatabaseManager.ISSZMBALV3_t_bd_item_info_item_no, stockno);
            row = localDatabaseHelper.deleteIsszmbalv3Stock(deleteValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static void deleteAllIsszmbalv3MemberInfoFromHistory(Context context) {
        HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
        localDatabaseHelper.deleteAllIsszmbalv3Members();
    }

    public static long deleteIsszmbalv3MemberInfoFromHistory(Context context, String cardid) {
        long row = -1;
        try {
            HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
            ContentValues deleteValues = new ContentValues();
            deleteValues.put(DatabaseManager.ISSZMBALV3_t_rm_vip_card_id, cardid);
            row = localDatabaseHelper.deleteIsszmbalv3Member(deleteValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }






    /**
     * 本地数据库历史搜索数据的存取
     *
     * @author taoli
     * @since 2015-0-10 下午04:57:36
     */
    public static long insertInputHistory(Context context, String initialValuesList) {
        long row = -1;
        try {
            HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
            localDatabaseHelper.insertInputHistory(initialValuesList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return row;
    }

    public static List<String> getAllInputHistory(Context context) {
        HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
        List<String> result = localDatabaseHelper.getAllInputHistory();
        return result;
    }

    public static void deleteAllInputHistory(Context context) {
        HistoryDatabaseHelper localDatabaseHelper = HistoryDatabaseHelper.getInstance(context);
        localDatabaseHelper.deleteAllInputHistor();
    }
}
